﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ScrumManagementToolUserControls
{
    /// <summary>
    /// Interaction logic for MenuBarUserControl.xaml
    /// </summary>
    public partial class MenuBarUserControl : UserControl
    {
        public MenuBarUserControl()
        {
            InitializeComponent();
        }

        #region menu button actions

        private void newProjectMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MainWindow mainWindow = GetTopParent() as MainWindow;
            mainWindow.diagNewProject.Visibility = Visibility.Visible;
        }

        private void exitMenuItem_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

        private void openProjectMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MainWindow mainWindow = GetTopParent() as MainWindow;
            mainWindow.diagOpenProject.Visibility = Visibility.Visible;
        }

        #endregion

        private Window GetTopParent()
        {
            DependencyObject dpParent = this.Parent;
            do
            {
                dpParent = LogicalTreeHelper.GetParent(dpParent);
            } while (dpParent.GetType().BaseType != typeof(Window));
            return dpParent as Window;
        }
    }
}
